﻿Imports GBDZafiro

Public Class FrmBcarGrupo
    Private gr As GBDZafiro.Grupo

    Public ReadOnly Property grupo() As GBDZafiro.Grupo
        Get
            Return gr
        End Get
    End Property

    Private Sub FrmBcarGrupo_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        cargargvGrupo()
    End Sub

    Private Sub gvGrupo_RowHeaderMouseClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles gvGrupo.RowHeaderMouseClick
        sendGrupo()
    End Sub

    Private Sub gvGrupo_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs)

    End Sub

    Private Sub gvGrupo_CellEnter(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvGrupo.CellEnter
        'sendGrupo()
    End Sub

    Private Sub gvGrupo_CellMouseDoubleClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles gvGrupo.CellMouseDoubleClick
        sendGrupo()
    End Sub

    Private Sub gvGrupo_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles gvGrupo.KeyDown
        If e.KeyCode = Keys.Enter Then
            sendGrupo()
        End If
    End Sub

    Private Sub sendGrupo()
        Dim rowgvGrupo As New DataGridViewRow()
        Dim gr As New GBDZafiro.Grupo

        rowgvGrupo = gvGrupo.CurrentRow

        gr.grupo = rowgvGrupo.Cells.Item("DESCRIPCION").Value.ToString()
        gr.idGrupo = rowgvGrupo.Cells.Item("ID_GRUPO").Value.ToString()
        Me.gr = gr

        DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub cargargvGrupo()
        gvGrupo.DataSource = Nothing
        gvGrupo.Rows.Clear()
        gvGrupo.DataSource = grupo.ConsultarAll()
        gvGrupo.Columns("ID_GRUPO").Visible = False
    End Sub
   
End Class